package com.sofwin.controller;

import com.sofwin.pojo.SUser;
import com.sofwin.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ClassName: TestController
 * Description: TODO
 * date: 2021/2/5 9:36 上午
 *
 * @author andyliu
 * @since JDK 1.8
 */
@Controller
public class TestController {

    @Autowired
    private TestService service;
    @RequestMapping("/test01")
    @ResponseBody
    public Map test01(){
        Map map = new HashMap();
        map.put("userName","admin");
        return map;
    }
    @RequestMapping("/test02")
    public String test02(Model model){
        final List<SUser> users = service.selectUsers();
        model.addAttribute("users",users);
        return "index";
    }
}
